var tpl = require('./index.html');
var style = require('./index.css');
var url = require('../../../utils/url.js');

module.exports = function(mod,name){	
	mod.directive(name,['$window','$routeParams',function($window,$routeParams){
		return {
			restrict: 'EA',
			replace: true,
			transclde: true,
			scope: {
				provinces: '=provinces',
				categories: '=categories',
				curCate: '=curCate',
				curPro: '=curPro'
			},
			template: tpl,
			link: function(scope, element, attrs){
				var $element = $(element);	
				$element.on('click','li',function(){
					var $this = $(this);	
					$this.siblings('li').removeClass('active');
					$this.addClass('active');
					var paths = url.getPaths();
					var path = '#/'+paths[1] +'/'+ paths[2];
					if($this.parents('.pro').length > 0){
						$window.location.href = path + '/1/'+$this.text()+'/'+$routeParams.cate;	
					}else {
						$window.location.href = path+'/1/'+$routeParams.pro+'/'+$this.text();	
					}
				});
			}
		}			
	}]);
}
